﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using EPiServer.Core;
using EPiServer.Security;

namespace EPiBoost.Core.Extensions
{
	public static class HtmlHelperExtensions
	{
		public static Func<IContent, bool> VisibleToVisitor(this HtmlHelper htmlHelper)
		{
			return (content) =>
			       	{
			       		var page = content as PageData;
			       		return page != null && (page.VisibleInMenu
			       		                        && page.CheckPublishedStatus(PagePublishedStatus.Published)
			       		                        && page.GetSecurityDescriptor().HasAccess(htmlHelper.ViewContext.HttpContext.User, AccessLevel.Read)
			       		                        && page.HasTemplate()
			       		                        && !page.PageLink.CompareToIgnoreWorkID(PageReference.WasteBasket));
			       	};
		}


		public static bool EditMode(this HtmlHelper html)
		{
			return Web.Mvc.Html.Helpers.EditMode(html);
		}

	}
}
